package demo1;

import com.sun.javaws.IconUtil;

class Shape{
    public void draw(){
        System.out.println("Shape::draw()");
    }
}

class Rect extends Shape{
    public void draw(){
        System.out.println("♦");
    }
}

class Flower extends Shape{
    public void draw(){
        System.out.println("❀");
    }
}

class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("△");
    }
}

class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("○");
    }
}

public class Test {
    public static void main(String[] args) {
        Rect rect = new Rect();
        Flower flower = new Flower();
        Triangle triangle = new Triangle();
        Cycle cycle = new Cycle();

        Shape[] shapes = {triangle,rect,triangle,rect,flower,cycle};
        for (Shape shape: shapes) {
            shape.draw();
        }
    }

    public static void main3(String[] args) {
        Rect rect = new Rect();
        Flower flower = new Flower();
        Triangle triangle = new Triangle();
        String[] shapes = {"triangle","rect","triangle","rect","flower"};
        for (String s:shapes) {
            if(s.equals("triangle")){
                triangle.draw();
            }else if(s.equals("rect")){
                rect.draw();
            }else{
                flower.draw();
            }
        }
    }

    public static void drawMap(Shape shape){
        shape.draw();
    }

    public static void main2(String[] args) {
        Rect rect = new Rect();
        drawMap(new Rect());
        Flower flower = new Flower();
        drawMap(new Flower());
        Triangle triangle = new Triangle();
        drawMap(triangle);
    }

    public static void main1(String[] args) {
        Rect rect = new Rect();
        rect.draw();
        Shape shape2 = new Flower();
        shape2.draw();
    }
}
